#include <iostream>
using namespace std;
using ll=long long;
int main() {

	ll n,m,a,b;
	ll llRet=0;
	cin>>n>>m>>a>>b;
	for(ll i=0;i<=n;++i){
		ll x=b*min(i,m/2);
		ll y=a*min(m-min(i,m/2)*2,(n-min(i,m/2))/2);
		llRet=max(llRet,x+y);
	}
	cout<<llRet;
	return 0;
}

